```html
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>网络技术全解析 - 从基础到实践</title>
    <link rel="stylesheet" href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css">
    <link rel="stylesheet" href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        :root {
            --primary: #2563eb;
            --secondary: #3b82f6;
            --accent: #60a5fa;
            --dark: #1e293b;
            --light: #f8fafc;
            --gray: #64748b;
        }
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Hiragino Sans GB", Simsun, sans-serif;
            color: var(--dark);
            line-height: 1.6;
            background-color: #f9fafb;
        }
        h1, h2, h3, h4, h5, h6 {
            font-family: 'Noto Serif SC', serif;
            font-weight: 600;
            color: var(--dark);
        }
        .hero {
            background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 100%);
        }
        .card {
            transition: all 0.3s ease;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
            border-radius: 0.5rem;
        }
        .card:hover {
            transform: translateY(-4px);
            box-shadow: 0 10px 15px rgba(0, 0, 0, 0.1);
        }
        .highlight {
            position: relative;
            z-index: 1;
        }
        .highlight:after {
            content: '';
            position: absolute;
            bottom: 0;
            left: 0;
            width: 100%;
            height: 30%;
            background-color: rgba(59, 130, 246, 0.2);
            z-index: -1;
            transform: scaleX(1.05);
            transition: all 0.3s ease;
        }
        .highlight:hover:after {
            height: 40%;
        }
        .code-block {
            font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
            background-color: #f3f4f6;
            border-left: 4px solid var(--primary);
            color: #1f2937;
        }
        .network-icon {
            width: 80px;
            height: 80px;
            display: flex;
            align-items: center;
            justify-content: center;
            border-radius: 50%;
            background-color: rgba(59, 130, 246, 0.1);
            color: var(--primary);
            font-size: 2rem;
            margin: 0 auto;
        }
        .diagram-container {
            background-color: white;
            border-radius: 0.5rem;
            padding: 1.5rem;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
        }
        .protocol-badge {
            display: inline-block;
            padding: 0.25rem 0.75rem;
            border-radius: 9999px;
            font-size: 0.875rem;
            font-weight: 500;
            margin-right: 0.5rem;
            margin-bottom: 0.5rem;
        }
        .tcp-badge {
            background-color: #dcfce7;
            color: #16a34a;
        }
        .udp-badge {
            background-color: #fef2f2;
            color: #dc2626;
        }
        .http-badge {
            background-color: #dbeafe;
            color: #2563eb;
        }
        .ip-badge {
            background-color: #f3e8ff;
            color: #7c3aed;
        }
        .animate-float {
            animation: float 6s ease-in-out infinite;
        }
        @keyframes float {
            0% { transform: translateY(0px); }
            50% { transform: translateY(-15px); }
            100% { transform: translateY(0px); }
        }
    </style>
</head>
<body class="antialiased">
    <!-- Hero Section -->
    <section class="hero text-white py-20 px-4 md:px-0">
        <div class="container mx-auto max-w-6xl">
            <div class="flex flex-col md:flex-row items-center">
                <div class="md:w-1/2 mb-10 md:mb-0">
                    <h1 class="text-4xl md:text-5xl font-bold mb-6">深入理解计算机网络</h1>
                    <p class="text-xl text-blue-100 mb-8">从基础概念到编程实践，全面掌握网络通信的核心技术</p>
                    <div class="flex space-x-4">
                        <a href="#net-basics" class="bg-white text-blue-600 hover:bg-blue-50 px-6 py-3 rounded-lg font-medium transition duration-300">开始学习</a>
                        <a href="#code-examples" class="border border-white text-white hover:bg-white hover:text-blue-600 px-6 py-3 rounded-lg font-medium transition duration-300">查看代码</a>
                    </div>
                </div>
                <div class="md:w-1/2 flex justify-center">
                    <div class="relative">
                        <div class="w-64 h-64 bg-blue-500 rounded-full opacity-20 absolute -top-10 -left-10"></div>
                        <div class="w-64 h-64 bg-blue-400 rounded-full opacity-20 absolute -bottom-10 -right-10"></div>
                        <div class="relative z-10 animate-float">
                            <img src="https://cdn.nlark.com/yuque/0/2023/png/21449790/1692782062918-6609de11-e7ee-41a7-8de8-23c9475285f3.png" alt="Network Illustration" class="w-full max-w-md">
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </section>

    <!-- Main Content -->
    <div class="container mx-auto max-w-6xl px-4 md:px-0 py-12">
        <!-- Network Basics Section -->
        <section id="net-basics" class="mb-20">
            <div class="flex items-center mb-10">
                <div class="h-1 bg-blue-500 w-16 mr-4"></div>
                <h2 class="text-3xl font-bold">网络基础概念</h2>
            </div>

            <div class="grid md:grid-cols-2 gap-8 mb-12">
                <div class="card bg-white p-6">
                    <div class="network-icon mb-6">
                        <i class="fas fa-project-diagram"></i>
                    </div>
                    <h3 class="text-2xl font-semibold mb-4">什么是网络？</h3>
                    <p class="text-gray-600 mb-4">网络是由点和线构成的系统，表示诸多对象间的相互联系。</p>
                    <img src="https://cdn.nlark.com/yuque/0/2023/png/21449790/1692782062918-6609de11-e7ee-41a7-8de8-23c9475285f3.png" alt="Network Diagram" class="rounded-lg mb-4 w-full">
                    <p class="text-gray-600">计算机网络是为实现资源共享和信息传递，通过通信线路连接起来的若干主机(Host)。</p>
                </div>

                <div class="card bg-white p-6">
                    <div class="network-icon mb-6">
                        <i class="fas fa-network-wired"></i>
                    </div>
                    <h3 class="text-2xl font-semibold mb-4">常见计算机网络类型</h3>
                    <div class="space-y-4">
                        <div class="flex items-start">
                            <div class="bg-blue-100 text-blue-600 p-2 rounded-lg mr-4">
                                <i class="fas fa-globe"></i>
                            </div>
                            <div>
                                <h4 class="font-medium">互联网 (Internet)</h4>
                                <p class="text-gray-600 text-sm">点与点相连的全球性网络</p>
                            </div>
                        </div>
                        <div class="flex items-start">
                            <div class="bg-blue-100 text-blue-600 p-2 rounded-lg mr-4">
                                <i class="fas fa-code-branch"></i>
                            </div>
                            <div>
                                <h4 class="font-medium">万维网 (WWW - World Wide Web)</h4>
                                <p class="text-gray-600 text-sm">端与端相连的超文本系统</p>
                            </div>
                        </div>
                        <div class="flex items-start">
                            <div class="bg-blue-100 text-blue-600 p-2 rounded-lg mr-4">
                                <i class="fas fa-microchip"></i>
                            </div>
                            <div>
                                <h4 class="font-medium">物联网 (IoT - Internet of Things)</h4>
                                <p class="text-gray-600 text-sm">物与物相连的智能网络</p>
                            </div>
                        </div>
                        <div class="flex items-start">
                            <div class="bg-blue-100 text-blue-600 p-2 rounded-lg mr-4">
                                <i class="fas fa-laptop-code"></i>
                            </div>
                            <div>
                                <h4 class="font-medium">网络编程</h4>
                                <p class="text-gray-600 text-sm">让计算机与计算机之间建立连接、进行通信</p>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

            <!-- Network Models Section -->
            <div class="grid md:grid-cols-2 gap-8">
                <div class="card bg-white p-6">
                    <h3 class="text-2xl font-semibold mb-4 flex items-center">
                        <i class="fas fa-layer-group text-blue-500 mr-3"></i>
                        OSI参考模型
                    </h3>
                    <p class="text-gray-600 mb-4">OSI（Open System Interconnect），即开放式系统互联。是ISO组织在1985年研究的网络互联模型。</p>
                    <img src="https://cdn.nlark.com/yuque/0/2023/png/21449790/1692782063673-143ab0c0-bb26-4793-92cb-faa7cd587632.png" alt="OSI Model" class="rounded-lg mb-4 w-full">
                    
                    <div class="space-y-3">
                        <div class="flex items-start">
                            <div class="bg-blue-500 text-white text-xs font-bold px-2 py-1 rounded mr-3 mt-1">7</div>
                            <div>
                                <h4 class="font-medium">应用层</h4>
                                <p class="text-gray-600 text-sm">负责文件访问和管理、可靠运输服务、远程操作服务 (HTTP、FTP、SMTP)</p>
                            </div>
                        </div>
                        <div class="flex items-start">
                            <div class="bg-blue-500 text-white text-xs font-bold px-2 py-1 rounded mr-3 mt-1">6</div>
                            <div>
                                <h4 class="font-medium">表示层</h4>
                                <p class="text-gray-600 text-sm">负责定义转换数据格式及加密，允许选择以二进制或ASCII格式传输</p>
                            </div>
                        </div>
                        <div class="flex items-start">
                            <div class="bg-blue-500 text-white text-xs font-bold px-2 py-1 rounded mr-3 mt-1">5</div>
                            <div>
                                <h4 class="font-medium">会话层</h4>
                                <p class="text-gray-600 text-sm">负责使应用建立和维持会话，使通信在失效时继续恢复通信 (断点续传)</p>
                            </div>
                        </div>
                        <div class="flex items-start">
                            <div class="bg-blue-500 text-white text-xs font-bold px-2 py-1 rounded mr-3 mt-1">4</div>
                            <div>
                                <h4 class="font-medium">传输层</h4>
                                <p class="text-gray-600 text-sm">负责是否选择差错恢复协议、数据流重用、错误顺序重排 (TCP、UDP)</p>
                            </div>
                        </div>
                        <div class="flex items-start">
                            <div class="bg-blue-500 text-white text-xs font-bold px-2 py-1 rounded mr-3 mt-1">3</div>
                            <div>
                                <h4 class="font-medium">网络层</h4>
                                <p class="text-gray-600 text-sm">负责定义了能够标识所有网络节点的逻辑地址 (IP地址)</p>
                            </div>
                        </div>
                        <div class="flex items-start">
                            <div class="bg-blue-500 text-white text-xs font-bold px-2 py-1 rounded mr-3 mt-1">2</div>
                            <div>
                                <h4 class="font-medium">链路层</h4>
                                <p class="text-gray-600 text-sm">在物理层上，通过规程或协议(差错控制)来控制传输数据的正确性 (MAC)</p>
                            </div>
                        </div>
                        <div class="flex items-start">
                            <div class="bg-blue-500 text-white text-xs font-bold px-2 py-1 rounded mr-3 mt-1">1</div>
                            <div>
                                <h4 class="font-medium">物理层</h4>
                                <p class="text-gray-600 text-sm">为设备之间的数据通信提供传输信号和物理介质 (双绞线、光导纤维)</p>
                            </div>
                        </div>
                    </div>
                </div>

                <div class="card bg-white p-6">
                    <h3 class="text-2xl font-semibold mb-4 flex items-center">
                        <i class="fas fa-sitemap text-blue-500 mr-3"></i>
                        TCP/IP模型
                    </h3>
                    <p class="text-gray-600 mb-4">TCP/IP模型是因特网使用的参考模型，基于TCP/IP的参考模型将协议分成四个层次。该模型中最重要的两个协议是TCP和IP协议。</p>
                    <img src="https://cdn.nlark.com/yuque/0/2023/png/21449790/1692782064028-32be95a1-481c-4687-a4b4-4af283abd67a.png" alt="TCP/IP Model" class="rounded-lg mb-4 w-full">
                    
                    <div class="space-y-3">
                        <div class="flex items-start">
                            <div class="bg-blue-500 text-white text-xs font-bold px-2 py-1 rounded mr-3 mt-1">4</div>
                            <div>
                                <h4 class="font-medium">应用层</h4>
                                <p class="text-gray-600 text-sm">负责传送各种最终形态的数据，是直接与用户打交道的层，典型协议是HTTP、FTP等</p>
                            </div>
                        </div>
                        <div class="flex items-start">
                            <div class="bg-blue-500 text-white text-xs font-bold px-2 py-1 rounded mr-3 mt-1">3</div>
                            <div>
                                <h4 class="font-medium">传输层</h4>
                                <p class="text-gray-600 text-sm">负责传送文本数据，主要协议是TCP、UDP协议</p>
                            </div>
                        </div>
                        <div class="flex items-start">
                            <div class="bg-blue-500 text-white text-xs font-bold px-2 py-1 rounded mr-3 mt-1">2</div>
                            <div>
                                <h4 class="font-medium">网络层</h4>
                                <p class="text-gray-600 text-sm">负责分配地址和传送二进制数据，主要协议是IP协议</p>
                            </div>
                        </div>
                        <div class="flex items-start">
                            <div class="bg-blue-500 text-white text-xs font-bold px-2 py-1 rounded mr-3 mt-1">1</div>
                            <div>
                                <h4 class="font-medium">接口层</h4>
                                <p class="text-gray-600 text-sm">负责建立电路连接，是整个网络的物理基础，典型的协议包括以太网、ADSL等</p>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </section>

        <!-- Network Programming Essentials -->
        <section class="mb-20">
            <div class="flex items-center mb-10">
                <div class="h-1 bg-blue-500 w-16 mr-4"></div>
                <h2 class="text-3xl font-bold">网络编程三要素</h2>
            </div>

            <div class="card bg-white p-6 mb-8">
                <div class="code-block p-4 rounded-lg overflow-x-auto">
                    <pre><code class="text-sm">/**
 * 网络编程三要素总结
 * 1、什么计算机网络（了解）
 *  为实现资源共享、信息传递通过传出介质将若干台主机连接到一起的一个网络
 *
 * 2、计算机网络模型（了解）
 *  OSI：
 *      应用层           主要指的是是程序
 *      表示层           将数据加密或者解密成二进制的数据
 *      会话层           保持主机之间的连接
 *      传输层           通过网络协议传输数据(TCP协议、UDP协议)
 *      网络层           分配IP地址(IP地址)
 *      网络数据链路层    保证准确性(MAC地址物理地址)
 *      物理层           进行数据传输
 *
 * 3、TCP/IP模型（了解）
 *      应用层
 *      传输层
 *      网络层
 *      物理层
 *
 * 4、网络编程需要什么？（重点）
 *      a、通信协议(TCP\UPD\HTTP)
 *      b、IP地址
 *      c、端口号
 *  网络编程三要素：协议、地址、端口号
 */</code></pre>
                </div>
            </div>

            <div class="grid md:grid-cols-3 gap-6">
                <div class="card bg-white p-6">
                    <h3 class="text-xl font-semibold mb-4 flex items-center">
                        <i class="fas fa-ethernet text-blue-500 mr-3"></i>
                        IP协议
                    </h3>
                    <p class="text-gray-600 mb-4">IP地址是分配给每一台主机的唯一数字标识，分为IPv4和IPv6两种版本。</p>
                    
                    <div class="space-y-3">
                        <div class="flex items-center">
                            <i class="fas fa-circle text-xs text-blue-500 mr-2"></i>
                            <span class="text-sm">IPv4: 4个字节32位组成，使用0~255之间的数字表示</span>
                        </div>
                        <div class="flex items-center">
                            <i class="fas fa-circle text-xs text-blue-500 mr-2"></i>
                            <span class="text-sm">IPv6: 16个字节128位组成，使用0~65535之间的数字表示</span>
                        </div>
                        <div class="flex items-center">
                            <i class="fas fa-circle text-xs text-blue-500 mr-2"></i>
                            <span class="text-sm">回路地址: 127.0.0.1 (localhost)</span>
                        </div>
                    </div>
                    
                    <div class="mt-4 p-4 bg-gray-50 rounded-lg">
                        <h4 class="font-medium text-sm mb-2">常用命令:</h4>
                        <div class="flex flex-wrap gap-2">
                            <span class="text-xs bg-gray-200 px-2 py-1 rounded">ipconfig</span>
                            <span class="text-xs bg-gray-200 px-2 py-1 rounded">ifconfig</span>
                            <span class="text-xs bg-gray-200 px-2 py-1 rounded">ping</span>
                        </div>
                    </div>
                </div>

                <div class="card bg-white p-6">
                    <h3 class="text-xl font-semibold mb-4 flex items-center">
                        <i class="fas fa-plug text-blue-500 mr-3"></i>
                        端口号
                    </h3>
                    <p class="text-gray-600 mb-4">端口号指的是每一个设备上程序的唯一数字标识，范围在0~65535之间。</p>
                    
                    <div class="space-y-3">
                        <div class="flex items-center">
                            <i class="fas fa-circle text-xs text-blue-500 mr-2"></i>
                            <span class="text-sm">公认端口号: 0~1023</span>
                        </div>
                        <div class="flex items-center">
                            <i class="fas fa-circle text-xs text-blue-500 mr-2"></i>
                            <span class="text-sm">注册端口号: 1024~49151</span>
                        </div>
                        <div class="flex items-center">
                            <i class="fas fa-circle text-xs text-blue-500 mr-2"></i>
                            <span class="text-sm">动态端口号: 49152~65536</span>
                        </div>
                    </div>
                    
                    <div class="mt-4 p-4 bg-gray-50 rounded-lg">
                        <h4 class="font-medium text-sm mb-2">常见端口号:</h4>
                        <div class="grid grid-cols-2 gap-2">
                            <div class="flex items-center">
                                <i class="fas fa-database text-xs text-gray-500 mr-2"></i>
                                <span class="text-xs">MySQL: 3306</span>
                            </div>
                            <div class="flex items-center">
                                <i class="fas fa-server text-xs text-gray-500 mr-2"></i>
                                <span class="text-xs">Tomcat: 8080</span>
                            </div>
                            <div class="flex items-center">
                                <i class="fas fa-globe text-xs text-gray-500 mr-2"></i>
                                <span class="text-xs">HTTP: 80</span>
                            </div>
                            <div class="flex items-center">
                                <i class="fas fa-cloud text-xs text-gray-500 mr-2"></i>
                                <span class="text-xs">FTP: 21</span>
                            </div>
                        </div>
                    </div>
                </div>

                <div class="card bg-white p-6">
                    <h3 class="text-xl font-semibold mb-4 flex items-center">
                        <i class="fas fa-exchange-alt text-blue-500 mr-3"></i>
                        通信协议
                    </h3>
                    <p class="text-gray-600 mb-4">定义计算机通信规则和约定，确保数据能够正确传输和解释。</p>
                    
                    <div class="space-y-3">
                        <div>
                            <span class="protocol-badge tcp-badge">TCP</span>
                            <p class="text-gray-600 text-sm mt-1">传输控制协议 - 面向连接、安全可靠、效率低、基于字节流</p>
                        </div>
                        <div>
                            <span class="protocol-badge udp-badge">UDP</span>
                            <p class="text-gray-600 text-sm mt-1">数据报协议 - 面向无连接、不安全、效率高、基于数据报包</p>
                        </div>
                        <div>
                            <span class="protocol-badge http-badge">HTTP</span>
                            <p class="text-gray-600 text-sm mt-1">超文本传输协议 - 用于分布式、协作式和超媒体信息系统的应用层协议</p>
                        </div>
                    </div>
                </div>
            </div>
        </section>

        <!-- Code Examples Section -->
        <section id="code-examples" class="mb-20">
            <div class="flex items-center mb-10">
                <div class="h-1 bg-blue-500 w-16 mr-4"></div>
                <h2 class="text-3xl font-bold">编程实践示例</h2>
            </div>

            <div class="grid md:grid-cols-2 gap-8">
                <!-- TCP Section -->
                <div>
                    <div class="flex items-center mb-6">
                        <span class="protocol-badge tcp-badge text-lg">TCP通信</span>
                        <h3 class="text-2xl font-semibold ml-3">基于TCP的客户端/服务端通信</h3>
                    </div>
                    
                    <div class="space-y-6">
                        <div class="card bg-white p-6">
                            <h4 class="font-semibold mb-3 flex items-center">
                                <i class="fas fa-laptop-code text-blue-500 mr-2"></i>
                                案例1: 基本通信
                            </h4>
                            <div class="code-block p-4 rounded-lg overflow-x-auto">
                                <pre><code class="text-sm">// 客户端
public class Client {
    public static void main(String[] args) throws IOException {
        // 1. 创建客户端Socket对象
        Socket socket = new Socket("127.0.0.1",6666);
        // 2. 获取输出流对象
        OutputStream out = socket.getOutputStream();
        // 3. 写出数据
        out.write("hello，我是客户端!!!".getBytes());
        // 4. 关闭资源
        out.close();
        socket.close();
    }
}

// 服务端
public class Server {
    public static void main(String[] args) throws IOException {
        // 1. 创建服务端Socket对象
        ServerSocket ss = new ServerSocket(6666);
        // 2. 获取Socket对象
        Socket socket = ss.accept();
        // 3. 获取输入流对象
        InputStream in = socket.getInputStream();
        // 4. 读取数据
        byte[] buf = new byte[1024];
        int len;
        while((len = in.read(buf)) != -1){
            System.out.println(new String(buf,0,len));
        }
        // 5. 关闭资源
        in.close();
        socket.close();
        ss.close();
    }
}</code></pre>
                            </div>
                        </div>

                        <div class="card bg-white p-6">
                            <h4 class="font-semibold mb-3 flex items-center">
                                <i class="fas fa-code-branch text-blue-500 mr-2"></i>
                                案例2: 多线程通信
                            </h4>
                            <div class="code-block p-4 rounded-lg overflow-x-auto">
                                <pre><code class="text-sm">// 客户端
public class Client {
    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
        while(true){
            Socket socket = new Socket("localhost",6677);
            OutputStream out = socket.getOutputStream();
            String words = sc.next();
            if("886".equals(words)||"over".equals(words)){
                out.close();
                socket.close();
                break;
            }
            out.write(words.getBytes());
            out.close();
            socket.close();
        }
    }
}

// 服务端
public class Server {
    public static void main(String[] args) throws IOException {
        ServerSocket ss = new ServerSocket(6677);
        System.out.println("服务端已开启等待客户端连接....");
        while(true){
            Socket socket = ss.accept();
            String ip = socket.getInetAddress().getHostAddress();
            new Thread(() -> {
                try {
                    InputStream in = socket.getInputStream();
                    BufferedReader br = new BufferedReader(new InputStreamReader(in));
                    String readLine = br.readLine();
                    System.out.println(ip+":"+readLine);
                    in.close();
                    socket.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }).start();
        }
    }
}</code></pre>
                            </div>
                        </div>

                        <div class="card bg-white p-6">
                            <h4 class="font-semibold mb-3 flex items-center">
                                <i class="fas fa-file-upload text-blue-500 mr-2"></i>
                                案例3: 文件上传
                            </h4>
                            <div class="code-block p-4 rounded-lg overflow-x-auto">
                                <pre><code class="text-sm">// 客户端
public class Client {
    public static void main(String[] args) throws IOException {
        Socket socket = new Socket("192.168.73.210",8899);
        OutputStream out = socket.getOutputStream();
        FileInputStream fis = new FileInputStream("d:\\41.jpg");
        byte[] buf = new byte[1024];
        int len;
        while((len = fis.read(buf))!=-1){
            out.write(buf,0,len);
        }
        socket.shutdownOutput();

        InputStream in = socket.getInputStream();
        BufferedReader br = new BufferedReader(new InputStreamReader(in));
        System.out.println(br.readLine());

        in.close();
        fis.close();
        out.close();
        socket.close();
    }
}

// 服务端
public class Server {
    public static void main(String[] args) throws IOException {
        ServerSocket ss = new ServerSocket(8899);
        System.out.println("图片服务器已开启....");
        while(true){
            Socket socket = ss.accept();
            new Thread(new UploadThread(socket)).start();
        }
    }
}

class UploadThread implements Runnable{
    Socket socket;
    public UploadThread(Socket socket){ this.socket = socket; }

    @Override
    public void run() {
        try {
            InputStream in = socket.getInputStream();
            String newFilename = UUID.randomUUID().toString().replace("-","");
            FileOutputStream fos = new FileOutputStream("upload\\"+newFilename+".jpg");

            byte[] buf = new byte[1024];
            int len;
            while((len = in.read(buf))!=-1){
                fos.write(buf,0,len);
            }
            
            OutputStream out = socket.getOutputStream();
            out.write(("success!!!"+"upload\\"+newFilename+".jpg").getBytes());

            out.close();
            fos.close();
            in.close();
            socket.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}</code></pre>
                            </div>
                        </div>
                    </div>
                </div>

                <!-- UDP & HTTP Section -->
                <div>
                    <div class="flex items-center mb-6">
                        <span class="protocol-badge udp-badge text-lg">UDP通信</span>
                        <h3 class="text-2xl font-semibold ml-3">基于UDP和HTTP的通信</h3>
                    </div>
                    
                    <div class="space-y-6">
                        <div class="card bg-white p-6">
                            <h4 class="font-semibold mb-3 flex items-center">
                                <i class="fas fa-paper-plane text-blue-500 mr-2"></i>
                                案例1: UDP基本通信
                            </h4>
                            <div class="code-block p-4 rounded-lg overflow-x-auto">
                                <pre><code class="text-sm">// 发送端
public class Send {
    public static void main(String[] args) throws Exception {
        DatagramSocket ds = new DatagramSocket();
        byte[] buf = "你好接收端".getBytes();
        DatagramPacket dp = new DatagramPacket(buf,buf.length, 
                             InetAddress.getByName("192.168.73.210"),9999);
        ds.send(dp);
        ds.close();
    }
}

// 接收端
public class Receive {
    public static void main(String[] args) throws Exception {
        DatagramSocket ds = new DatagramSocket(9999);
        byte[] buf = new byte[1024];
        DatagramPacket dp = new DatagramPacket(buf,buf.length);
        ds.receive(dp);

        byte[] data = dp.getData();
        InetAddress inetAddress = dp.getAddress();
        int port = dp.getPort();
        int length = dp.getLength();

        String str = new String(data,0,length);
        System.out.println("ip:"+inetAddress.getHostAddress());
        System.out.println("port:"+port);
        System.out.println("data:"+str);

        ds.close();
    }
}</code></pre>
                            </div>
                        </div>

                        <div class="card bg-white p-6">
                            <h4 class="font-semibold mb-3 flex items-center">
                                <i class="fas fa-comment-dots text-blue-500 mr-2"></i>
                                案例2: UDP飞秋通信
                            </h4>
                            <div class="code-block p-4 rounded-lg overflow-x-auto">
                                <pre><code class="text-sm">public class Send {
    public static void main(String[] args) throws Exception {
        DatagramSocket ds = new DatagramSocket();
        byte[] buf = "1:100:主机名:昵称:32:hello，飞秋".getBytes("GBK");
        DatagramPacket dp = new DatagramPacket(buf,buf.length, 
                             InetAddress.getByName("192.168.73.210"),2425);
        ds.send(dp);
        ds.close();
    }
}</code></pre>
                            </div>
                        </div>

                        <div class="flex items-center mt-8 mb-6">
                            <span class="protocol-badge http-badge text-lg">HTTP通信</span>
                            <h3 class="text-2xl font-semibold ml-3">基于HTTP的通信</h3>
                        </div>

                        <div class="card bg-white p-6">
                            <h4 class="font-semibold mb-3 flex items-center">
                                <i class="fas fa-download text-blue-500 mr-2"></i>
                                案例1: HTTP下载图片
                            </h4>
                            <div class="code-block p-4 rounded-lg overflow-x-auto">
                                <pre><code class="text-sm">public class TestHttp {
    public static void main(String[] args) throws Exception {
        URL url = new URL("https://img12.360buyimg.com/pop/s1180x940_jfs/t1/57426/21/17071/50837/61357401E8e1fda44/a900941b30ae30c9.jpg.webp");
        HttpURLConnection connection = (HttpURLConnection) url.openConnection();
        if(connection.getResponseCode() == 200){
            InputStream in = connection.getInputStream();
            FileOutputStream fos = new FileOutputStream("download\\"+
                              UUID.randomUUID().toString().replace("-","")+".jpg");
            byte[] buf = new byte[1024];
            int len;
            while((len = in.read(buf))!=-1){
                fos.write(buf,0,len);
            }
            System.out.println("success");
            fos.close();
            in.close();
            connection.disconnect();
        }
    }
}</code></pre>
                            </div>
                        </div>

                        <div class="card bg-white p-6">
                            <h4 class="font-semibold mb-3 flex items-center">
                                <i class="fas fa-spider text-blue-500 mr-2"></i>
                                案例2: 网络爬虫获取邮箱
                            </h4>
                            <div class="code-block p-4 rounded-lg overflow-x-auto">
                                <pre><code class="text-sm">public class TestHttp2 {
    public static void main(String[] args) throws Exception{
        URL url = new URL("https://www.ais.cn/news/article/2975");
        HttpURLConnection connection = (HttpURLConnection) url.openConnection();
        if(connection.getResponseCode() == 200){
            InputStream in = connection.getInputStream();
            BufferedReader br = new BufferedReader(new InputStreamReader(in));
            String line;

            Pattern pattern = Pattern.compile(
                "[0-9a-zA-Z_]{5,20}@[0-9a-z]{2,12}\\.(com|cn|org|edu)");

            while((line = br.readLine()) != null){
                Matcher matcher = pattern.matcher(line);
                while(matcher.find()){
                    System.out.println(matcher.group());
                }
            }
            in.close();
            connection.disconnect();
        }
    }
}</code></pre>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </section>

        <!-- Summary Section -->
        <section class="mb-20">
            <div class="flex items-center mb-10">
                <div class="h-1 bg-blue-500 w-16 mr-4"></div>
                <h2 class="text-3xl font-bold">综合练习与总结</h2>
            </div>

            <div class="card bg-white p-6">
                <h3 class="text-2xl font-semibold mb-4 flex items-center">
                    <i class="fas fa-tasks text-blue-500 mr-3"></i>
                    用户注册登录系统
                </h3>
                <p class="text-gray-600 mb-6">基于TCP协议实现多线程用户注册登录功能，结合集合、IO流、网络编程等技术。</p>
                
                <div class="grid md:grid-cols-2 gap-6">
                    <div>
                        <h4 class="font-semibold mb-3 text-lg">要求:</h4>
                        <ul class="space-y-2 text-gray-600">
                            <li class="flex items-start">
                                <i class="fas fa-check-circle text-blue-500 mr-2 mt-1"></i>
                                <span>基于TCP协议考虑多线程</span>
                            </li>
                            <li class="flex items-start">
                                <i class="fas fa-check-circle text-blue-500 mr-2 mt-1"></i>
                                <span>客户端向服务端注册用户，服务端接收用户信息</span>
                            </li>
                            <li class="flex items-start">
                                <i class="fas fa-check-circle text-blue-500 mr-2 mt-1"></i>
                                <span>如果注册成功保存到文件中，并返回注册成功还是失败(用户名不重复)</span>
                            </li>
                            <li class="flex items-start">
                                <i class="fas fa-check-circle text-blue-500 mr-2 mt-1"></i>
                                <span>客户端向服务端登录用户，服务端接收用户信息</span>
                            </li>
                            <li class="flex items-start">
                                <i class="fas fa-check-circle text-blue-500 mr-2 mt-1"></i>
                                <span>从文件中查询是否有该用户信息，返回登录成功还是失败</span>
                            </li>
                        </ul>
                    </div>
                    <div>
                        <h4 class="font-semibold mb-3 text-lg">技术点:</h4>
                        <div class="flex flex-wrap gap-2">
                            <span class="protocol-badge tcp-badge">TCP协议</span>
                            <span class="protocol-badge">多线程</span>
                            <span class="protocol-badge">集合框架</span>
                            <span class="protocol-badge">IO流</span>
                            <span class="protocol-badge">文件操作</span>
                            <span class="protocol-badge">网络编程</span>
                            <span class="protocol-badge">客户端/服务端</span>
                        </div>
                    </div>
                </div>
            </div>
        </section>
    </div>

    <!-- Footer -->
    <footer class="bg-gray-900 text-white py-8">
        <div class="container mx-auto max-w-6xl px-4 md:px-0">
            <div class="flex flex-col md:flex-row justify-between items-center">
                <div class="mb-4 md:mb-0">
                    <h3 class="text-xl font-bold">技术小馆</h3>
                    <p class="text-gray-400 mt-1">探索技术世界的奥秘</p>
                </div>
                <div>
                    <a href="http://www.yuque.com/jtostring" class="text-blue-400 hover:text-blue-300 transition duration-300">
                        <i class="fas fa-external-link-alt mr-2"></i>
                        http://www.yuque.com/jtostring
                    </a>
                </div>
            </div>
            <div class="border-t border-gray-800 mt-8 pt-8 text-center text-gray-500 text-sm">
                &copy; 2023 技术小馆. 保留所有权利.
            </div>
        </div>
    </footer>

    <script>
        mermaid.initialize({
            startOnLoad: true,
            theme: 'default',
            flowchart: {
                useMaxWidth: false,
                htmlLabels: true,
                curve: 'basis'
            }
        });
    </script>
</body>
</html>
```